import time
from multiprocessing import Process
import os


def one():
    print('子进程一', os.getpid(), os.getppid())


def two():
    print('子进程二', os.getpid(), os.getppid())


li = []


def wdata():
    for i in range(5):
        li.append(i)
        time.sleep(0.5)
    print('现在的li是这样的：', li)


def rdata():
    print('读取li的数据：', li)


if __name__ == '__main__':
    p1 = Process(target=one)
    p2 = Process(target=two, name='two')

    p1.start()
    p2.start()
    print(p1.name, p2.name)
    print(p1.pid, p2.pid)

    w = Process(target=wdata)
    r = Process(target=rdata)
    w.start()
    w.join()
    r.start()
    r.join()
